--
-- Author: mm
-- Date: 2018-08-07 12:08:34
--
-- NewBossHeadRender
-- 地城boss信息UIboss头像render

local ClassRef = app.mvc.createRenderClass(...)

--data =
function ClassRef.createWithData(data, node)
    local sprite = ClassRef.extend(node or cc.CSLoader:createNode(Res.NewTeamBossHeadNode, true, false))
    if node == nil then
        ccui.Helper:doLayout(sprite)
    end
    sprite:init(data)
    return sprite
end
function ClassRef.create(node)
    return ClassRef.createWithData(nil, node)
end

--
function ClassRef:init(data)
    self.super.init(self, data)
    self:setContentSize( self._ui.Panel:getContentSize() )

     display.uiAddClick( self._ui.Panel, function()
        executeFunc( self._onClick )
     end)

    self:refresh()
end

function ClassRef:refresh()
    if self._data then
        self:setVisible( true )

        local data = self._data

        local bossHeadPath = GD:getImagePath( Res.npcIconPath, data.face )
        if bossHeadPath then
            self._ui.icon:loadTexture( bossHeadPath )
        end
    else
        self:setVisible( false )
    end
end

function ClassRef:setSelected(b)
    self._ui.selected:setVisible( b )
end

function ClassRef:onBtnClick(cb)
    self._onClick = cb
end

return ClassRef
